<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>${name_china}管理-编辑${name_china}</title>
<%@include file="/common/head.jsp" %>
<style>
/***按钮选中态****/
.pitchbut{
	background:#f86b67;
	color:#fff;
}
</style>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>编辑${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="form" method="post">
    <div class="form-wrapper">
      
      <div class="form-cont">
      <p class="form-cont-title">我的昵称</p>
      <input type="text" id="nickName" name="nickName" class="summer-input summer-validatebox"/>
      <input type="hidden" id="userId" name="userId" class="summer-input summer-validatebox"/>
      <input type="hidden" id="storeId" name="storeId"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的店铺头像</p>
      <input type="hidden"  id="storeImg" name="storeImg"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的店铺背景图</p>
      <input type="hidden"  id="backgoundImg" name="backgoundImg"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的团队人员</p>
      <input type="text"  id="teamCount" name="teamCount"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的惠金币</p>
      <input type="text"  id="points" name="points"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的账户余额</p>
      <input type="text"  id="balance" name="balance"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">提现金额</p>
      <input type="text"  id="withdraw" name="withdraw"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的预估收入</p>
      <input type="text"  id="preIncome" name="preIncome"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的店铺预估订单</p>
      <input type="text"  id="preProfitCount" name="preProfitCount"/>
      </div>
      <div class="form-cont">
      <p class="form-cont-title">我的店铺实际订单</p>
      <input type="text"  id="totalProfitCount" name="totalProfitCount"/>
      </div>
      <!-- <div class="form-cont">
      <p class="form-cont-title">我分享商品</p>
      <input type="text" class="summer-input" id="title"/>
      </div> -->
      <div class="form-cont">
      <p class="form-cont-title">我店铺总交易额</p>
      <input type="text"  id="totalSale" name="totalSale"/>
      </div>
     <div class="form-btn-wrapper" id="funcbar">
     <a class="btn btn-normal" id="backBtn">关闭</a>
    </div>
  </div>
</form>
<table class="summer-datagrid" style="width:auto">   
      <thead class="orderhead">
        	<tr>
	    		<th><div class="summer-datagrid-cell"><a id="toPreIncome" href="javascript:;">预估明细</a></div></th>
	    		<th><div class="summer-datagrid-cell"><a id="toIncome" href="javascript:;">收入明细</a></div></th>
	    		<th><div class="summer-datagrid-cell"><a id="toWithdraw" href="javascript:;">提现明细</a></div></th>
	    		<th><div class="summer-datagrid-cell  pitchbut"><a id="toOrder" href="javascript:;">店铺订单</a></div></th>
<!-- 	    		<th><div class="summer-datagrid-cell"><a id="toShare" href="javascript:;">分享明细</a></div></th>
 -->	    		<th><div class="summer-datagrid-cell"><a id="toTeam" href="javascript:;">团队明细</a></div></th>
	    	</tr>
      </thead>    
  </table>
  <div class="search-field">  
	<span class="field-cont">
        <span class="field-cont-title">商品名称/ID</span>
        <input type="text" class="summer-input" id="goodsName"/>
    </span>
    <span class="field-cont">
        <span class="field-cont-title">订单号</span>
        <input type="text" class="summer-input" id="orderNo"/>
    </span>
     <span class="field-cont">
        <span class="field-cont-title">订单来源</span>
        <input type="text" id="preIncomeChannel" name="preIncomeChannel" class="summer-input summer-validatebox"/>        
        <input type="hidden" class="summer-input" id="preType" value="both"/>
        <input type="hidden" class="summer-input" id="preIncomeType" value="PI003"/> 
    </span><br/>
   <!-- 
     <span class="field-cont">
        <span class="field-cont-title">用户角色</span>
        <input type="text" class="summer-input" id="type"/>
    </span><br/> -->
     <span class="field-cont">
        <span class="field-cont-title">成交时间</span>
        <input type="text" class="summer-input" id="createTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/>
    </span>
     <span class="field-cont">
        <span class="field-cont-title">至</span>
        <input type="text" class="summer-input" id="updateTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/>
    </span>
    
    <span class="field-cont">
        <span class="field-cont-title">结算状态</span>
        <input type="text" class="summer-input" id="jiesuan" class="summer-input summer-validatebox"/>
    </span>
    <span class="field-btn-wrapper">
        <a id="search" class="btn btn-primary btn-icon wave distance-right"><i class="icon icon-search"></i></a>
        <a id="reset" class="btn btn-icon wave wave-dark"><i class="icon icon-refresh"></i></a>
    </span>
</div>
<div id="t-wrap">
    <table class="summer-datagrid" id="dataList">
	    <col width="10%">
	    <col width="30%">
	    <col width="20%">
	    <col width="20%">
	    <col width="10%">
	    <col width="10%">
	    <col width="10%">
	    <col width="20%">
	    <col width="20%">
	    <thead>
		     <tr>
		    <th><div class="summer-datagrid-cell">订单来源</div></th>
		    <th><div class="summer-datagrid-cell">商品名称</div></th>
		    <th><div class="summer-datagrid-cell">订单号</div></th>
		    <th><div class="summer-datagrid-cell">手机号</div></th>
		    <th><div class="summer-datagrid-cell">级别</div></th>
		    <th><div class="summer-datagrid-cell">佣金</div></th>
		    <th><div class="summer-datagrid-cell">实际收款</div></th>
		    <th><div class="summer-datagrid-cell">支付方式</div></th>
		    <th><div class="summer-datagrid-cell">结算状态</div></th>
			 </tr>
	    </thead>
    </table>
</div>
<script>
    
  var   editData,
        permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	editData = ${editData};
    	$("#storeId").val(${storeId});
    	//初始化funcbar
     	 $('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:edit']
        })); 
    	
    	
     	 $('#form').form({
        	onLoadSuccess:function(data){
           }
        }).form('loadDataEdit', {
            data: editData
        });
     	$("#storeImg").filePlugin();
    	$("#backgoundImg").filePlugin();
    	//T_DM_T_PAY_USER_LOG_IS_JIESUAN
    	$('#jiesuan').combobox({
             valueField : 'code',
             textField : 'name',
             url : COMMON_URL.getCode + '?type=T_DM_T_PAY_USER_LOG_IS_JIESUAN'
         });
    	$('#preIncomeChannel').combobox({
             valueField : 'code',
             textField : 'name',
             url : COMMON_URL.getCode + '?type=T_DM_T_PAY_USER_LOG_PRE_INCOME_CHANNEL'
         });
    	//重置按钮
        $('#reset').on('click', function () {
        	//重置文本框的值
        	$('#preIncomeChannel').combobox('clear');
    		$('#orderNo').val('');
    		$('#goodsName').val('');
    		$('#jiesuan').combobox('clear');
    		$('#createTime').val('');
    		$('#updateTime').val('');        	
        	reloadTable();
        });
        $('#search').on('click', reloadTable);
     	createTable();
    	//保存按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:edit"]', submit);
    	$('#toPreIncome').on('click',toPreIncome);
    	$('#toIncome').on('click',toIncome);
    	$('#toWithdraw').on('click',toWithdraw);
    	$('#toOrder').on('click',toOrder);
    	$('#toShare').on('click',toShare);
    	$('#toTeam').on('click',toTeam);
    	//返回按钮
    	$('#backBtn, #goBack').on('click',backMain);
    });
    function reloadTable() {
		$('#dataList').datagrid('reload',{
            ajax: {
            	param: {
            		"preIncomeChannel": trimSpace($('#preIncomeChannel').combobox('getValue')),
            		"preType": trimSpace($('#preType').val()),
            		//"preIncomeType": trimSpace($('#preIncomeType').val()),
            		"jiesuan": trimSpace($('#jiesuan').combobox('getValue')),
            		"orderNo": trimSpace($('#orderNo').val()),
            		"goodsName": trimSpace($('#goodsName').val()),
            		"createTime": trimSpace($('#createTime').val()),
            		"updateTime": trimSpace($('#updateTime').val()), 
            		"userId": trimSpace($('#userId').val())
            	}
            }
        });
	}
    function createTable() {
    	$('#dataList').datagrid({
    		ajax: {
    			url: CONST_URL.ORDER,
    			param: {
    				"preIncomeChannel": trimSpace($('#preIncomeChannel').combobox('getValue')),
            		"preType": trimSpace($('#preType').val()),
            		//"preIncomeType": trimSpace($('#preIncomeType').val()),
            		"jiesuan": trimSpace($('#jiesuan').combobox('getValue')),
            		"orderNo": trimSpace($('#orderNo').val()),
            		"goodsName": trimSpace($('#goodsName').val()),
            		"createTime": trimSpace($('#createTime').val()),
            		"updateTime": trimSpace($('#updateTime').val()), 
            		"userId": trimSpace($('#userId').val())
            	}
    		},
    		columns: [
    		     {
    		    	 field: 'id',
    		    	 hidden: true
    		     },
    		     {
    		    	 field: 'channel'
    		     },
    		     {
    		    	 field: 'goodsName'
    		     },
    		     {
    		    	 field: 'orderNo'
    		     },
    		     {
    		    	 field: 'userPhone'
    		     },
    		     {
    		    	 field: 'level'
    		     },
    		     {
    		    	 field: 'commission'
    		     },
    		     {
    		    	 field: 'actualPay'
    		     },
    		     {
    		    	 field: 'payType'
    		     },
    		     {
    		    	 field: 'preType' 
    		     }
    	    ]
    	});
    }
    
    //表单提交
    function submit() {
         $("#form").form({
        	 buttons : ['#saveBtn'],
             ajax: {
                 url: CONST_URL.EDIT
             },
             onSubmitSuccess: function (data) {
            	 $.stip({
   	                type:'ok',//显示类型 有info、 ok、 danger
   	                text: '保存成功！',
   	                onBeforeHide: function () {
   	                	backMain();
   	                }
            	 });
              }
         }).form("submit");
    }

    function toPreIncome(){
    	var  id = trimSpace($('#storeId').val())
    	window.location.href = CONST_URL.INIT_PRE_INCOME+"?id="+id;
    }
    function toIncome(){
    	var  id = trimSpace($('#storeId').val())
    	window.location.href = CONST_URL.INIT_INCOME+"?id="+id;
    }
    function toWithdraw(){
    	var  id = trimSpace($('#storeId').val())
    	window.location.href = CONST_URL.INIT_WITHDRAW+"?id="+id;
    }
    function toOrder(){
    	var  id = trimSpace($('#storeId').val())
    	window.location.href = CONST_URL.INIT_ORDER+"?id="+id;
    }
    function toShare(){
    	var  id = trimSpace($('#storeId').val())
    	window.location.href = CONST_URL.INIT_SHARE+"?id="+id;
    }
    function toTeam(){
    	var  id = trimSpace($('#storeId').val())
    	window.location.href = CONST_URL.INIT_TEAM+"?id="+id;
    }
  //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_MAIN;
    }
    //请求url
     var CONST_URL = {
    	INIT_MAIN: basePath + "${common_url}init",
       	EDIT: basePath + "${common_url}edit",
       	PRE_INCOME: basePath + "${common_url}preIncome",
       	INCOME: basePath + "${common_url}actualIncome",
       	INIT_INCOME: basePath + "${common_url}initActualIncome",
       	WITHDRAW: basePath + "${common_url}getWithdraw",
       	INIT_WITHDRAW: basePath + "${common_url}initWithdraw",
       	ORDER: basePath + "${common_url}getOrder",
       	INIT_ORDER: basePath + "${common_url}initOrder",
       	SHARE: basePath + "${common_url}getShare",
       	TEAM: basePath + "${common_url}getTeam",
       	INIT_TEAM: basePath + "${common_url}initTeam",
       	INIT_PRE_INCOME: basePath + "${common_url}initPreIncome"
    };
    
    
</script>
</body>
</html>